package com.vnp.vchat.task;

import java.util.ArrayList;

import android.content.Context;

import com.telpoo.frame.model.BaseModel;
import com.telpoo.frame.model.BaseTask;
import com.telpoo.frame.model.TaskParams;
import com.vnp.vchat.bean.ObjKhachhang;
import com.vnp.vchat.net.NetSupport;
import com.vnp.vchat.util.Common;

public class Task extends BaseTask implements TaskType{

	public Task(BaseModel baseModel, int taskType, ArrayList<?> list, Context context) {
		super(baseModel, taskType, list, context);
		// TODO Auto-generated constructor stub
	}
	
	@Override
	protected Boolean doInBackground(TaskParams... params) {
		switch (taskType) {
		case TASK_VGID2CHATID:
			Common.idVchat=null;
			String userId= (String) dataFromModel.get(0);  //userid la ben anh Toan
			String senderId= (String) dataFromModel.get(1); // la cua ng dang nhap
			String hash= (String) dataFromModel.get(2);
			
			NetData netdata= NetSupport.vgid2chatid(userId,senderId,hash);
			if(netdata.status!=0){
				msg= netdata.getMessage();
				return TASK_FAILED;
			}
			
			
			
			ObjKhachhang objKhachhang = new ObjKhachhang();
            objKhachhang.setUrlAvatar("");
            objKhachhang.setName("");
            objKhachhang.setAddress("");
            objKhachhang.setDsDaxem("");
            objKhachhang.setId(""+netdata.data.toString());
            objKhachhang.setTxtWebsite("");
            objKhachhang.setOnline(1);
            objKhachhang.setUrlDangxem("");
            Common.toNotify = true;
            Common.ojGcm = objKhachhang;
			
			return TASK_DONE;
			
			

		default:
			break;
		}
		
		
		
		
		
		
		
		
		
		
		return super.doInBackground(params);
	}

}
